package com.sss.springcloud.controller;

import ch.qos.logback.core.net.SyslogOutputStream;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.context.ContextUtil;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
 * 降级规则测试
 * @author sss
 * @date 2020-03-11 10:04
 **/
@RestController
public class DegradeLimitController {



    @GetMapping("/testA")
    public String testA(){
        System.out.println(new Date()+"/t"+Thread.currentThread().getName()+"\t");
        System.out.println("\ttestA");
        return "------------testA"+"\t";
    }
    @GetMapping("/testB")
    public String testB(){
        System.out.println("\ttestB");
        return "------------testB"+"\t";
    }

    @GetMapping("/testC")
    public String testC(){
         try {
                     TimeUnit.SECONDS.sleep(1);
                 } catch (InterruptedException e) {
                     e.printStackTrace();
                 }
        System.out.println("RT****Test");
        return "------------testC";
    }

    @GetMapping("/testD")
    public String testD(){
        System.out.println("异常比例****Test");
        int age=10/0;
        return "------------testD";
    }
    @GetMapping("/testE")
    public String testE(){
        System.out.println("异常数****Test");
        int age=10/0;
        return "------------testE";
    }




}
